{include file="public/head" /}
<script type="text/javascript" src="static/admin/js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="static/admin/css/area.css" />
<body>

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>后台管理</cite></a>
        <a><cite>物业管理系统</cite></a>
        <a><cite>员工管理</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so"  method="get" action="{:url('index')}">
      <!--<div id="addAddress" >
         <div class="address_input"><input class="address_input1" type="text" placeholder="请选择省市" id="shengshi" onClick="getProvinceBuy()" readonly="readonly"></div>
     </div>
     <div id="yzl" >

     </div>
      <div class="layui-input-inline" id="community_id" style="font-size: 20px;border:1px solid #ccc;width:150px" onclick="x_admin_show('添加小区','{:url('address')}',550,600)" >选择小区</div>
      <div class="layui-input-inline" id="group" style="font-size: 20px;border:1px solid #ccc;width:150px">选择组团</div>
      <div class="layui-input-inline" id="building" style="font-size: 20px;border:1px solid #ccc;width:150px">选择楼栋</div>
      <div class="layui-input-inline" id="unit" style="font-size: 20px;border:1px solid #ccc;width:150px">选择单元</div>
      <div class="layui-input-inline" id="room" style="font-size: 20px;border:1px solid #ccc;width:150px">选择房屋</div>-->
      <div class="layui-input-inline">
        <select name="community_id" lay-filter="community_id" id="community_id">
          <option value="">所属小区</option>
          {foreach $communitylist as $name}
          <option value="{$name.community_id}" {if isset($community_id)}{if $community_id == $name.community_id}selected{/if}{/if}>{$name.community_name}</option>
          {/foreach}
        </select>
      </div>

      <input class="layui-input" placeholder="姓名" name="owner_name" value="{if isset($owner_name)}{$owner_name}{/if}">
      <input class="layui-input" placeholder="电话" name="owner_phone" value="{if isset($owner_phone)}{$owner_phone}{/if}">


      <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
    <div style="color:red">
      新用户初始密码:654321
    </div>
  </div>
  <xblock>

    <button class="layui-btn" onclick="x_admin_show('添加用户','{:url('add')}',550,600)"><i class="layui-icon"></i>添加管理员</button>


    <!--        <button class="layui-btn" onclick="roomExportExcel('{$export}')"><i class="layui-icon"></i>批量导出</button>-->
    <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
  </xblock>
  <table class="layui-table" id="table">
    <thead  style="text-align:center;">
    <tr>
      <th style="width: 4%;text-align:center;">
        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
      </th>
      <th style="text-align: center; font-size: 16px;">小区</th>
      <th style="text-align: center; font-size: 16px;">手机号码</th>
      <th style="text-align: center; font-size: 16px;">姓名</th>
      <th style="text-align: center; font-size: 16px;">user_id</th>


      <th style="text-align: center; font-size: 16px;">操作</th>
    </tr>
    </thead>
    <tbody style="text-align:center;">
    {foreach $list as $val}
    <tr>
      <td style="text-align: center;">
        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$val.id}'><i class="layui-icon">&#xe605;</i></div>
      </td>
      <td style="text-align: center;">{$val.community_name}</td>


      <td style="text-align: center;">{$val.mobile}</td>
      <td style="text-align: center;">{$val.name}</td>
      <td style="text-align: center;">{$val.openid}</td>

      <td style="text-align: center;">
          <a title="编辑"  onclick="x_admin_show('编辑','{:url('passwordedit')}?id={$val.id}',550,600)" href="javascript:;">
            <i class="layui-icon">&#xe642;</i>
          </a>



        {if $Think.session.usertype=="0"}


        {/if}
      </td>
    </tr>
    {/foreach}
    </tbody>
  </table>
  <div class="page">
    <div>
      {$pagelist->render()}
    </div>
  </div>

</div>


<script>

  layui.use('laydate', function(){
    var laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });
  });

  //删除
  function roominfoDelId(id, doc){
    if(confirm('删除后无法恢复，确定要删除吗?'))
    {
      var url = "{:url('roominfoDelId')}?id=" + id
      // console.log(url)
      $('#' + doc).attr('href', url)
    }
    return false;
  }
  //批量删除
  function delAll () {
    var datas = $('#table tbody td .layui-form-checked')
    var ids = []
    datas.each(function(index, element){
      var id = $(this).data('id')
      ids.push(id)
    })

    var str = ids.join(',');
    var count = ids.length
    layer.confirm('你确定要删除这'+ count + '项吗', function(){
      $.post('{:url("admin/Roominfo/roominfoDel")}', {id: str}, function(r){
        if(r.info){
          layer.msg(r.info);
          setTimeout(function (){

            window.location.reload();
          }, 700)
        }else{
          layer.msg(r.error)
          setTimeout(function (){

            window.location.reload();
          }, 700)
        }
      })
    })
  }

  //批量导出
  function roomExportExcel(exportid){
    var datas = $('#table tbody td .layui-form-checked')
    var ids = []
    datas.each(function(index, element){
      var id = $(this).data('id')
      ids.push(id)
    })

    var str = ids.join(',');
    var count = ids.length
    var url = "{:url('admin/Roominfo/roomExportExcel')}?id=" + str +'&export=' + exportid
    layer.open({
      type: 2,
      title: '批量导出房屋',
      shadeClose: true,
      shade: 0.8,
      area: ['80%', '95%'],
      content: url //iframe的url
    });
  }

</script>
<!-- 搜索 -->
<script>
  layui.use(['form'], function() {
    var form = layui.form
    form.on('select(community_id)', function(f){
      var url = "{:url('admin/Roominfo/fetchdata')}"
      $.post(url, {community_id: f.value, type: 1}, function(data) {
        $('#group').html("")
        var option = "<option value=''>所有组团</option>"
        $('#group').append(option)
        for (var i = 0; i < data.length; i++) {
          option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
          $('#group').append(option)
        }

        form.render('select')
      })

      $('#community_id').data('community_id', f.value)

    })

    form.on('select(group)', function(f){
      var data_community = $('#community_id').data('community_id')
      var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
      var community_id = typeof data_community === 'undefined' ? get_community : data_community
      var url = "{:url('admin/Roominfo/fetchdata')}"
      $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
        $('#building').html("")
        var option = "<option value=''>所有楼栋</option>"
        $('#building').append(option)
        for (var i = 0; i < data.length; i++) {
          option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
          $('#building').append(option)
        }
        $('#group').data('group', f.value)
        form.render('select')
      })
    })

    form.on('select(building)', function(f){
      var data_community = $('#community_id').data('community_id')
      var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
      var community_id = typeof data_community === 'undefined' ? get_community : data_community

      var data_group = $('#group').data('group')
      var get_group = "<?php if (isset($group)) { echo $group;}?>"
      var group = typeof data_group === 'undefined' ? get_group : data_group

      var url = "{:url('admin/Roominfo/fetchdata')}"
      $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
        $('#unit').html("")
        var option = "<option value=''>所有单元</option>"
        $('#unit').append(option)
        for (var i = 0; i < data.length; i++) {
          option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
          $('#unit').append(option)
        }
        $('#building').data('building', f.value)
        form.render('select')
      })
    })

    form.on('select(unit)', function(f){
      var data_community = $('#community_id').data('community_id')
      var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
      var community_id = typeof data_community === 'undefined' ? get_community : data_community

      var data_group = $('#group').data('group')
      var get_group = "<?php if (isset($group)) { echo $group;}?>"
      var group = typeof data_group === 'undefined' ? get_group : data_group

      var data_building = $('#building').data('building')
      var get_building = "<?php if (isset($building)) { echo $building;}?>"
      var building = typeof data_building === 'undefined' ? get_building : data_building

      var url = "{:url('admin/Roominfo/fetchdata')}"
      $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
        $('#room').html("")
        var option = "<option value=''>所有房间</option>"
        $('#room').append(option)
        for (var i = 0; i < data.length; i++) {
          option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
          $('#room').append(option)
        }
        $('#unit').data('unit', f.value)
        form.render('select')
      })
    })

  })
</script>

<script>var _hmt = _hmt || []; (function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>

</html>